package com.order.mapper;

import com.order.bean.Tables;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface TablesMapper {

    @Insert("insert into tables (no, unit, free, user_id)" +
            "values (#{no}, #{unit}, #{free}, #{userId})")
    boolean insert(Tables tables);

    boolean update(Tables tables);

    @Delete("delete from tables where id = #{id}")
    boolean deleteById(Integer id);

    @Select("select * from tables where id = #{id}")
    Tables seletById(Integer id);

    @Select("select * from tables where user_id = #{userId}")
    Tables selectByUserId(Integer userId);


    List<Tables> selectAll(String name);

    @Update("update tables set user_id = null, free = '是' where id = #{id}")
    void removeOrder(Integer id);

}
